﻿using System.Configuration;
using EnterpriseLibraryExtensions.PolicyInjection.UnityBridge;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;

namespace PolicyInjection
{
    internal class Program
    {
        private static void Main()
        {
            // Create an empty Unity Container that is Policy Injection enabled.
            UnityPolicyExtension.CreateUnityContainer();

            // Make an existing Unity Container Policy Injection enabled.
            var existingContainer = new UnityContainer();
            existingContainer.AddNewExtension<UnityPolicyExtension>();

            // Instantiate Unity Container from configuration file with Policy Injection Enabled.
            // Have a look in app.config to see how it works.
            var configuredContainer = new UnityContainer();
            var section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
            section.Configure(configuredContainer);
        }
    }
}
